﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DataMining.DataAccess;
using System.Data.SqlClient;
using DataMining.Bean;
using System.Data;


using DataMining.Control.Transport;

namespace DataMining
{
    /// <summary>
    /// ProBar.xaml 的交互逻辑
    /// </summary>
    public partial class ProBar : Window
    {
        private int probar_count = 0;
        private int total_count = 0;
        private DateTime create_time;

        public ProBar()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 初始化进度条，确定最大值和最小值
        /// </summary>
        /// <param name="cre_time"></param>
        public ProBar(DateTime cre_time)      //初始化的时候传入create_time
        {
            InitializeComponent();
            create_time = cre_time;
            GetNum Num = new GetNum();
            TransporByTable trans = new TransporByTable();
           
            //取数据时间内的数据总量
            total_count = Num.GetDBcount("Patient_Information", create_time, create_time.AddDays(3));

            progressBar1.Minimum = 0;
            progressBar1.Maximum = total_count;

        }

        /// <summary>
        /// 查找数据库，通过进度条显示已经存入的数据
        /// </summary>
        public void ProbarAdd()
        {
        //    progressBar1.Visibility = true;

            //已存入的大于create_time的数据
            GetNum Num = new GetNum();
            probar_count = Num.GetCount2("Patient_Information", create_time);

            string note = "";
            if (progressBar1.Value < total_count)
            {
                progressBar1.Value =probar_count;
              
                note="读取数据" + progressBar1.Value.ToString() + "条";
            }
            else
            {
                progressBar1.Value = total_count;
                note = "读取数据完毕！一共" + progressBar1.Value.ToString() + "条数据。";
            }

            label1.Content = note;
     
        }


    }
}
